﻿create procedure [dbo].[usp_ExceptionUpdate] 
	@ExceptionId int
	, @ConcurrencyId timestamp
	, @PublicationId uniqueidentifier
	, @AppDomainId int
	, @AssemblyId int
	, @MachineId int
	, @IIdentityId int
	, @ProcessId int
	, @TargetSiteId int
	, @ThreadId int
	, @WorkItemId int
	, @ExceptionType nvarchar(255)
	, @HelpLink nvarchar(512)
	, @HResult int
	, @IsTransient bit
	, @Message nvarchar(512)
	, @Source nvarchar(512)
	, @StackTrace nvarchar(max)
	, @Unhandled bit
	, @FirstChance bit
	, @SerializedDictionaryXml xml
	, @SerializedExceptionXml xml
	, @XElement xml
as

begin try
	
	begin transaction
	
		update [dbo].[Exception]
		set
			[PublicationId] = @PublicationId
			, [AppDomainId] = @AppDomainId
			, [AssemblyId] = @AssemblyId
			, [MachineId] = @MachineId
			, [IIdentityId] = @IIdentityId
			, [ProcessId] = @ProcessId
			, [TargetSiteId] = @TargetSiteId
			, [ThreadId] = @ThreadId
			, [WorkItemId] = @WorkItemId
			, [ExceptionType] = @ExceptionType
			, [HelpLink] = @HelpLink
			, [HResult] = @HResult
			, [IsTransient] = @IsTransient
			, [Message] = @Message
			, [Source] = @Source
			, [StackTrace] = @StackTrace
			, [Unhandled] = @Unhandled
			, [FirstChance] = @FirstChance
			, [SerializedDictionaryXml] = @SerializedDictionaryXml
			, [SerializedExceptionXml] = @SerializedExceptionXml
			, [XElement] = @XElement
		where [ExceptionId] = @ExceptionId and [ConcurrencyId] = @ConcurrencyId
		
	commit transaction

end try
	
begin catch
	if @@trancount > 0
	begin
		rollback transaction;
	end
	execute [dbo].[usp_SqlErrorInsert]
end catch